import time

from engine.sniffer import Sniffer
from engine.broker import Broker
from structure.buffer import FrameBuffer
from module.activeflows import OutputActiveFlows

if __name__ == "__main__":
    
    def cb(pktlen,pkt,ts):
        print ts," => ",pktlen," bytes"
       
    pynetstats_outputs = [
                          cb
                          ]
    
    pynetstats_buffer = FrameBuffer()
    pynetstats_sniffer = Sniffer(
                                 interface="eth0",
                                 snaplen=4096,
                                 promiscmode=True,
                                 callback=pynetstats_buffer.append
                                 )

    pynetstats_broker = Broker(
                               callbacks=pynetstats_outputs,
                               frameBuffer=pynetstats_buffer
                               )
    pynetstats_broker.start()
    pynetstats_sniffer.start()
    pynetstats_sniffer.startCapture()
    
    raw_input("Press any key...")
   
    pynetstats_sniffer.stop()
    pynetstats_broker.stop()
    
    